package com.aco.party.web.validator.system;

import com.aco.party.web.command.system.EditLinksCommand;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by flying on 3/10/2016 0010.
 */
public class EditLinksValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return EditLinksCommand.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "linkName", "error.linkName.empty", "名称不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "linkUrl", "error.linkUrl.empty", "链接不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "linkRating", "error.linkRating.empty", "排序不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "linkVisible", "error.linkVisible.empty", "状态不能为空");
        EditLinksCommand command = (EditLinksCommand) o;
    }
}
